<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>元旦倒计时</title>
	<script>
	function NewYear(){
		var newYear = new Date('2018-01-01 00:00:00');
		var now =new Date();
		var timeDifference=newYear.getTime()-now.getTime();
		day=Math.floor(timeDifference/(1000*60*60*24));
		dd=timeDifference/(1000*60*60*24);
		day=Math.floor(dd);
		hh=(dd-day)*24;
		hour=Math.floor(hh);
		mm=(hh-hour)*60;
		minutes=Math.floor(mm);
		ss=(mm-minutes)*60;
		second= Math.floor(ss);

		document.getElementById('txt').innerHTML="There are "+day+" days "+hour+" hours "+minutes+" minutes "+second+" seconds from NewYear !";
		t=setTimeout('NewYear()',500);
	}
	</script>
</head>
<body onload="NewYear()">
	<div id="txt"></div>
</body>
</html>